class EmailAddress {
  User user
  String email
  Boolean isMain = false

  static belongsTo = [user: User]

  static constraints = {
    user(nullable: false)
    email(blank: false, email: true, unique: true)
    isMain(nullable: false)
  }

  static mapping = {
    sort "email"
  }


  public String toString() {
    return "${email} ${isMain ? '(main)' : ''}"
  }
}
